{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "## SQuAD2.0训练集数据分析"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### SQuAD2.0训练集数据下载\n",
    "[SQuAD2.0训练集下载地址](https://rajpurkar.github.io/SQuAD-explorer/dataset/train-v2.0.json)\n",
    "\n",
    "[SQuAD2.0验证集下载地址](https://rajpurkar.github.io/SQuAD-explorer/dataset/dev-v2.0.json)\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### SQuAD2.0训练集内容一览(取第一个人物话题为例)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "is_executing": false
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "text": [
      "****************************************************************************************************\ntitle[1]: Beyoncé\n****************************************************************************************************\ncontext[1]:\nBeyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an American singer, songwriter, record producer and actress. Born and raised in Houston, Texas, she performed in various singing and dancing competitions as a child, and rose to fame in the late 1990s as lead singer of R&B girl-group Destiny's Child. Managed by her father, Mathew Knowles, the group became one of the world's best-selling girl groups of all time. Their hiatus saw the release of Beyoncé's debut album, Dangerously in Love (2003), which established her as a solo artist worldwide, earned five Grammy Awards and featured the Billboard Hot 100 number-one singles \"Crazy in Love\" and \"Baby Boy\".\n\nid: 56be85543aeaaa14008c9063\nquestion[1]: When did Beyonce start becoming popular?\nanswer[1]: in the late 1990s\nis_impossible False\n-------------------------------------------------------------------------------------------------\nid: 56be85543aeaaa14008c9065\nquestion[2]: What areas did Beyonce compete in when she was growing up?\nanswer[1]: singing and dancing\nis_impossible False\n-------------------------------------------------------------------------------------------------\nid: 56be85543aeaaa14008c9066\nquestion[3]: When did Beyonce leave Destiny's Child and become a solo singer?\nanswer[1]: 2003\nis_impossible False\n-------------------------------------------------------------------------------------------------\nid: 56bf6b0f3aeaaa14008c9601\nquestion[4]: In what city and state did Beyonce  grow up? \nanswer[1]: Houston, Texas\nis_impossible False\n-------------------------------------------------------------------------------------------------\nid: 56bf6b0f3aeaaa14008c9602\nquestion[5]: In which decade did Beyonce become famous?\nanswer[1]: late 1990s\nis_impossible False\n-------------------------------------------------------------------------------------------------\nid: 56bf6b0f3aeaaa14008c9603\nquestion[6]: In what R&B group was she the lead singer?\nanswer[1]: Destiny's Child\nis_impossible False\n-------------------------------------------------------------------------------------------------\nid: 56bf6b0f3aeaaa14008c9604\nquestion[7]: What album made her a worldwide known artist?\nanswer[1]: Dangerously in Love\nis_impossible False\n-------------------------------------------------------------------------------------------------\nid: 56bf6b0f3aeaaa14008c9605\nquestion[8]: Who managed the Destiny's Child group?\nanswer[1]: Mathew Knowles\nis_impossible False\n-------------------------------------------------------------------------------------------------\nid: 56d43c5f2ccc5a1400d830a9\nquestion[9]: When did Beyoncé rise to fame?\nanswer[1]: late 1990s\nis_impossible False\n-------------------------------------------------------------------------------------------------\nid: 56d43c5f2ccc5a1400d830aa\nquestion[10]: What role did Beyoncé have in Destiny's Child?\nanswer[1]: lead singer\nis_impossible False\n-------------------------------------------------------------------------------------------------\nid: 56d43c5f2ccc5a1400d830ab\nquestion[11]: What was the first album Beyoncé released as a solo artist?\nanswer[1]: Dangerously in Love\nis_impossible False\n-------------------------------------------------------------------------------------------------\nid: 56d43c5f2ccc5a1400d830ac\nquestion[12]: When did Beyoncé release Dangerously in Love?\nanswer[1]: 2003\nis_impossible False\n-------------------------------------------------------------------------------------------------\nid: 56d43c5f2ccc5a1400d830ad\nquestion[13]: How many Grammy awards did Beyoncé win for her first solo album?\nanswer[1]: five\nis_impossible False\n-------------------------------------------------------------------------------------------------\nid: 56d43ce42ccc5a1400d830b4\nquestion[14]: What was Beyoncé's role in Destiny's Child?\nanswer[1]: lead singer\nis_impossible False\n-------------------------------------------------------------------------------------------------\nid: 56d43ce42ccc5a1400d830b5\nquestion[15]: What was the name of Beyoncé's first solo album?\nanswer[1]: Dangerously in Love\nis_impossible False\n-------------------------------------------------------------------------------------------------\n"
     ],
     "output_type": "stream"
    }
   ],
   "source": [
    "import json\n",
    "path = r'F:\\dataset_download\\SQuaD2.0\\train-v2.0.json'\n",
    "with open(path, 'r+', encoding='utf-8') as f:\n",
    "    json_data = json.load(f)\n",
    "    data = json_data['data']\n",
    "    for i in range(1):\n",
    "        print('*' * 100)\n",
    "        print('title[{}]:'.format(i + 1), data[i]['title'])\n",
    "        para = data[i]['paragraphs']\n",
    "        # for j in range(len(para)):\n",
    "        # 以第一个情景为例\n",
    "        for j in range(1):\n",
    "            qas = para[j]['qas']\n",
    "            print('*' * 100)\n",
    "            context = para[j]['context']\n",
    "            print('context[{}]:'.format(j + 1) + '\\n' + context + '\\n')\n",
    "            for k in range(len(qas)):\n",
    "                print('id:', qas[k]['id'])\n",
    "                print('question[{}]:'.format(k + 1), qas[k]['question'])\n",
    "                answers = qas[k]['answers']\n",
    "                # 可能有多个回答\n",
    "                for n in range(len(answers)):\n",
    "                    print('answer[{}]:'.format(n + 1), answers[n]['text'])\n",
    "                print('is_impossible', qas[k]['is_impossible'])\n",
    "                print('-' * 97)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}